<?php

require_once 'common/conn.php';
$data = array();
if (isset($_GET['productversion'])) {
    $db = new DBC();
    $productversion = $_GET['productversion'];

    $products = json_decode($productversion, true);
    foreach ($products as $v) {
        $v['flashcode'];
        $sql = "SELECT flashcode,version,url_en AS url FROM t_product WHERE status_en = 1 AND flashcode = '" . $v['flashcode'] . "' ORDER BY flashcode";
        $temp = $db->fetchData($sql);
        $obj = array();
        if (count($temp) > 0) {
            $obj['flashcode'] = $temp[0]['flashcode'];
            $obj['version'] = $temp[0]['version'];
            $obj['url'] = $temp[0]['url'];
        }
        array_push($data, $obj);
    }
}
echo json_encode($data);
?>